home *** CD-ROM | disk | FTP | other *** search
- // itgdmdoc.cpp : implementation of the CItgDemoDoc class
- //
-
- #include "stdafx.h"
- #include "itgdemo.h"
-
- #include "itgdmdoc.h"
- #include "itgdmvw.h"
-
- #include "itgdefs.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CItgDemoDoc
-
- IMPLEMENT_DYNCREATE(CItgDemoDoc, CDocument)
-
- BEGIN_MESSAGE_MAP(CItgDemoDoc, CDocument)
- //{{AFX_MSG_MAP(CItgDemoDoc)
- ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
- ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
- ON_COMMAND(ID_FILE_NEW, OnFileNew)
- ON_COMMAND(ID_FILE_SAVE, OnFileSave)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CItgDemoDoc construction/destruction
-
- CItgDemoDoc::CItgDemoDoc()
- {
- }
-
- CItgDemoDoc::~CItgDemoDoc()
- {
- }
-
- BOOL CItgDemoDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
-
- // TODO: add reinitialization code here
- // (SDI documents will reuse this document)
-
- return TRUE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CItgDemoDoc serialization
-
- void CItgDemoDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CItgDemoDoc diagnostics
-
- #ifdef _DEBUG
- void CItgDemoDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
-
- void CItgDemoDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CItgDemoDoc commands
-
- void CItgDemoDoc::OnFileSaveAs()
- {
- POSITION pos = GetFirstViewPosition();
- CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
- CFileDialog dlgSaveAs(FALSE, "itg", "*.itg", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY,
- "ITGraph Files (*.itg) | *.itg | All Files (*.*) | *.* ||", pFirstView);
- if(dlgSaveAs.DoModal() == IDOK) {
- CVBControl *pITG = pFirstView->m_ITGraph;
- SetPathName(dlgSaveAs.GetPathName());
- pITG->SetStrProperty("SaveAs", GetPathName());
- }
- }
-
- void CItgDemoDoc::OnFileOpen()
- {
- POSITION pos = GetFirstViewPosition();
- CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
- if(pFirstView->AskToSave()) {
- CFileDialog dlgOpen(TRUE, "itg", "*.itg", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY,
- "ITGraph Files (*.itg) | *.itg | All Files (*.*) | *.* ||", pFirstView);
- dlgOpen.m_ofn.nFilterIndex = 1;
- if(dlgOpen.DoModal() == IDOK) {
- CVBControl *pITG = pFirstView->m_ITGraph;
- SetPathName(dlgOpen.GetPathName());
- pITG->SetStrProperty("LoadFrom", GetPathName());
- pITG->SetNumProperty("IsDirty", FALSE);
- }
- }
- }
-
- void CItgDemoDoc::OnFileNew()
- {
- POSITION pos = GetFirstViewPosition();
- CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
- if(pFirstView->AskToSave()) {
- CVBControl *pITG = pFirstView->m_ITGraph;
- SetTitle("");
- pITG->SendMessage(VBM_METHOD, METH_CLEAR, 0L);
- }
- }
-
- void CItgDemoDoc::OnFileSave()
- {
- POSITION pos = GetFirstViewPosition();
- CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
- if((GetPathName() == "") || (GetTitle() == ""))
- OnFileSaveAs();
- else {
- CVBControl *pITG = pFirstView->m_ITGraph;
- pITG->SetStrProperty("SaveAs", GetPathName());
- }
- }
-